package com.iisigroup.project.statistics.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.ArrayUtils;

/**
 * The Class Func4Moi.
 */
public class Func4Moi implements Serializable {

    /** The Constant serialVersionUID. */
    private static final long serialVersionUID = 4727683832238393983L;

    /** 作業代號. */
    private String symbol;

    /** 作業名稱. */
    private String operationName;

    /** 畫面. */
    private List<String> pages;

    /** 程式代號. */
    private List<String> javaCodes;

    /** 代碼檔(properties). */
    private List<String> properties;

    /** 資料庫Table(含RSCD Table). */
    private List<String> tables;

    /** 報表代號. */
    private List<String> reportSymbols;

    /** 檔案代號. */
    private List<String> filesSymbols;

    /** The display lines. */
    private List<String[]> displayLines;

    /**
     * Gets the display lines.
     * 
     * @return the display lines
     */
    public List<String[]> getDisplayLines() {
        if (this.displayLines == null) {
            this.displayLines = new ArrayList<String[]>();
        } else {
            this.displayLines.clear();
        }
        /***
         * 目前已知的column數目為9
         * **/

        /***
         * 找出最大行數
         * ****/
        int fileSymbolsLength = getFilesSymbols().size();
        int javaCodesSize = getJavaCodes().size();
        int pagesSize = getPages().size();
        int proertiesSize = getProperties().size();
        int reportSymbolsSize = getReportSymbols().size();
        int tablesSize = getTables().size();
        /***
         * 得到最大行數
         * ****/
        int lineMax = NumberUtils
                .max(new int[] { fileSymbolsLength, javaCodesSize, pagesSize,
                        proertiesSize, reportSymbolsSize,tablesSize , 1 });
        
        for (int i = 0; i < lineMax; ++i) {
            final String[] line = new String[9];
            
            switch (i) {
            case 0:
                line[0] = this.symbol;
                line[1] = this.operationName;

                break;
            default:
                line[0] = StringUtils.EMPTY;
                line[1] = StringUtils.EMPTY;
                break;
            }
            
            if (this.pages.size() > i) {
                line[2] = getPages().get(i);
            }else {
                line[2] = StringUtils.EMPTY;
            }
            
            if (this.javaCodes.size() > i) {
                line[3] = getJavaCodes().get(i);
            }else {
                line[3] = StringUtils.EMPTY;
            }
            
            if (this.properties.size() > i) {
                line[4] = getProperties().get(i);
            }else {
                line[4] = StringUtils.EMPTY;
            }
            
            if (this.tables.size() > i) {
                line[5] = getTables().get(i);
            }else {
                line[5] = StringUtils.EMPTY;
            }
            
            if (this.reportSymbols.size() > i) {
                line[6] = getReportSymbols().get(i);
            }else {
                line[6] = StringUtils.EMPTY;
            }
            
            if (this.filesSymbols.size() > i) {
                line[7] =  getFilesSymbols().get(i);
            }else {
                line[7] = StringUtils.EMPTY;
            }
            line[8] = StringUtils.EMPTY;
            this.displayLines.add(line);
        }

        return this.displayLines;
    }

    /**
     * Sets the display lines.
     * 
     * @param displayLines
     *            the new display lines
     */
    public void setDisplayLines(List<String[]> displayLines) {
        this.displayLines = displayLines;
    }

    /**
     * Gets the symbol.
     * 
     * @return the symbol
     */
    public String getSymbol() {
        return symbol;
    }

    /**
     * Sets the symbol.
     * 
     * @param symbol
     *            the new symbol
     */
    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    /**
     * Gets the operation name.
     * 
     * @return the operation name
     */
    public String getOperationName() {
        return operationName;
    }

    /**
     * Sets the operation name.
     * 
     * @param operationName
     *            the new operation name
     */
    public void setOperationName(String operationName) {
        this.operationName = operationName;
    }

    /**
     * Gets the pages.
     * 
     * @return the pages
     */
    public List<String> getPages() {
        if (pages == null) {
            pages = new ArrayList<String>();
        }
        return pages;
    }

    /**
     * Sets the pages.
     * 
     * @param pages
     *            the new pages
     */
    public void setPages(List<String> pages) {
        this.pages = pages;
    }

    /**
     * Gets the java codes.
     * 
     * @return the java codes
     */
    public List<String> getJavaCodes() {
        if (javaCodes == null) {
            javaCodes = new ArrayList<String>();
        }
        return javaCodes;
    }

    /**
     * Sets the java codes.
     * 
     * @param javaCodes
     *            the new java codes
     */
    public void setJavaCodes(List<String> javaCodes) {
        this.javaCodes = javaCodes;
    }

    /**
     * Gets the properties.
     * 
     * @return the properties
     */
    public List<String> getProperties() {
        if (properties == null) {
            properties = new ArrayList<String>();
        }
        return properties;
    }

    /**
     * Sets the properties.
     * 
     * @param properties
     *            the new properties
     */
    public void setProperties(List<String> properties) {
        this.properties = properties;
    }

    /**
     * Gets the tables.
     * 
     * @return the tables
     */
    public List<String> getTables() {
        if (tables == null) {
            tables = new ArrayList<String>();
        }
        return tables;
    }

    /**
     * Sets the tables.
     * 
     * @param tables
     *            the new tables
     */
    public void setTables(List<String> tables) {
        this.tables = tables;
    }

    /**
     * Gets the report symbols.
     * 
     * @return the report symbols
     */
    public List<String> getReportSymbols() {
        if (reportSymbols == null) {
            reportSymbols = new ArrayList<String>();
        }
        return reportSymbols;
    }

    /**
     * Sets the report symbols.
     * 
     * @param reportSymbols
     *            the new report symbols
     */
    public void setReportSymbols(List<String> reportSymbols) {
        this.reportSymbols = reportSymbols;
    }

    /**
     * Gets the files symbols.
     * 
     * @return the files symbols
     */
    public List<String> getFilesSymbols() {
        if (filesSymbols == null) {
            filesSymbols = new ArrayList<String>();
        }
        return filesSymbols;
    }

    /**
     * Sets the files symbols.
     * 
     * @param filesSymbols
     *            the new files symbols
     */
    public void setFilesSymbols(List<String> filesSymbols) {
        this.filesSymbols = filesSymbols;
    }

}
